package main

import (
	"fmt"
	"os"

	"github.com/spf13/cobra"
	"techoiceness.com/aiagent/llm-gateway/internal/auth"
)

var generateJWTSecretCmd = &cobra.Command{
	Use:   "generate-jwt-secret",
	Short: "生成JWT密钥",
	Long:  `生成一个用于JWT签名的随机密钥`,
	Run: func(cmd *cobra.Command, args []string) {
		secret, err := auth.GenerateRandomSecret()
		if err != nil {
			fmt.Fprintf(os.Stderr, "错误: 生成JWT密钥失败: %v\n", err)
			os.Exit(1)
		}

		fmt.Println("已生成JWT密钥:")
		fmt.Printf("jwt_secret = \"%s\"\n", secret)
		fmt.Println("\n请将此密钥添加到您的config.toml文件的[server]部分。")
	},
}
